//
//  AddWorkerViewController.m
//  MagictoHire
//
//  Created by 锋 on 2017/12/23.
//  Copyright © 2017年 HUAYU. All rights reserved.
//

#import "AddWorkerViewController.h"
#import "SpecialWorkerViewController.h"
#import "ProjectEditViewController.h"

@interface AddWorkerViewController ()<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
@property (nonatomic, strong) UITableView *addWorkerTableView;
//@property (nonatomic, strong) SelectWorkKindModel *selectWorkModel;
@end

@implementation AddWorkerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self setupAddWorkerTableView];
    // Do any additional setup after loading the view.
}

- (void)setupUI {
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"添加工人";
    self.view.backgroundColor = RGB(242, 242, 242);
}
- (void)setupAddWorkerTableView {
    _addWorkerTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - STA_NAV_HEIGHT - SCREER_HeiX) style:UITableViewStyleGrouped];
    _addWorkerTableView.delegate = self;
    _addWorkerTableView.dataSource = self;
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.000001)];
    view.backgroundColor = [UIColor whiteColor];
    _addWorkerTableView.tableHeaderView = view;
    _addWorkerTableView.tableFooterView = view;
    _addWorkerTableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_addWorkerTableView];
}

// MARK:tableview的方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.000001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.000001;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *ID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
    if (indexPath.row == 0) {
        cell.textLabel.text = @"普工";
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    } else {
        cell.textLabel.text = @"特种工人";
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.textColor = RGB(77, 77, 77);
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        SpecialWorkerModel *model  = [[SpecialWorkerModel alloc] init];
        model.name = @"普工";
        model.ID = @"1";
        self.addWorkerBlock(model);
        [self.navigationController popViewControllerAnimated:YES];
    } else if (indexPath.row == 1) {
        SpecialWorkerViewController *specialWorkerVC = [[SpecialWorkerViewController alloc] init];
        [self.navigationController pushViewController:specialWorkerVC animated:YES];
    }
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
